package top.tomxwd.springcloud.service.fallback;

import feign.hystrix.FallbackFactory;
import org.springframework.stereotype.Component;
import top.tomxwd.springcloud.pojo.Dept;
import top.tomxwd.springcloud.service.DeptClientService;

import java.util.List;

/**
 * @author xieweidu
 * @createDate 2020-06-18 0:03
 */
@Component
public class DeptClientServiceFallbackFactory implements FallbackFactory<DeptClientService> {
    @Override
    public DeptClientService create(Throwable throwable) {
        return new DeptClientService() {
            @Override
            public Dept get(Long id) {
                System.out.println("id = " + id);
                return new Dept().setDeptno(id).setDname("该ID: " + id + "没有找到对应的信息,null--@HystrixCommand")
                        .setDbSource("no this database in MySQL");
            }

            @Override
            public List<Dept> queryAll() {
                return null;
            }

            @Override
            public boolean addDept(Dept dept) {
                return false;
            }
        };
    }
}
